using MethodChaining.MFComputer.Model;



namespace MethodChaining.MFComputer.Builders
{
	public class DiskBuilder
	{
		private readonly ComputerBuilder _parent;
		private int _size;
		private int _speed;
		private bool _sata;





		public DiskBuilder( ComputerBuilder parent )
		{
			_parent = parent;
		}





		public static implicit operator ComputerBuilder( DiskBuilder builder )
		{
			return builder.DoneAction();
		}





		private ComputerBuilder DoneAction()
		{
			_parent.AddDisk( new Disk( _size, _speed, _sata ) );
			return _parent;
		}





		public static implicit operator Computer( DiskBuilder builder )
		{
			ComputerBuilder computerBuilder = builder;
			return computerBuilder;
		}





		public DiskBuilder WithDisk
		{
			get { return DoneAction().WithDisk; }
		}



		public DiskBuilder IsSata
		{
			get
			{
				_sata = true;
				return this;
			}
		}



		public ComputerBuilder Done
		{
			get { return DoneAction(); }
		}





		public DiskBuilder OfSize( int size )
		{
			_size = size;
			return this;
		}





		public DiskBuilder OfSpeed( int speed )
		{
			_speed = speed;
			return this;
		}
	}
}